import cv2
import matplotlib.pyplot as plt

#img=cv2.imread("C:\\qx\\document\\4.5.5\\4.5.5\\lena.jpg")
#print(img)
#cv2.imshow("chen",img)
#cv2.waitKey(0)

#img1= cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
#plt.subplot(1,3,1)
#plt.imshow(img1)
#plt.show()


  


def recordFunction():
    output_path = './output03.avi'
    vc = cv2.VideoCapture(1,cv2.CAP_DSHOW)
    #vc = cv2.VideoCapture(1,cv2.cap)
    flag = vc.isOpened()
    if(flag):
        ret, frame = vc.read()
        w = int(vc.get(cv2.CAP_PROP_FRAME_WIDTH))
        h = int(vc.get(cv2.CAP_PROP_FRAME_HEIGHT))
        fps = vc.get(cv2.CAP_PROP_FPS)
    
        # fourcc = cv2.VideoWriter_fourcc('H', '2', '6', '4')
        # fourcc = cv2.VideoWriter_fourcc('X', 'V', 'I', 'D')
        # fourcc = cv2.VideoWriter_fourcc('H', 'E', 'V', 'C')

        fourcc = cv2.VideoWriter_fourcc(*'XVID')

        vw = cv2.VideoWriter(output_path, fourcc, 20.0, (w,h), True)

    

        while ret:
            vw.write(frame)
            ret, frame = vc.read()
            cv2.imshow('frame', frame)
            if (cv2.waitKey(5) & 0xFF) == ord('q'):
                break;
        vc.release()
        vw.release()
        cv2.destroyAllWindows()
